odoo.define('lmch_buliao.open_report', function (require) {
    "use strict";

    var core = require('web.core');
    var crash_manager = require('web.crash_manager');
    var framework = require('web.framework');
    var session = require('web.session');

    var open_report = function (element, action) {

        var active_id = action.params.active_id;
        var report_name = action.params.report_name;
        var report_type = action.params.report_type
        var report_url = '/report/'+report_type+'/'+report_name+'/'+active_id
        window.open(report_url, '_blank')

    };
    // http://127.0.0.1:8069/report/html/lmch_buliao.report_produceplan/7

    var cfprint_report = function(element, action){
        var _reportDatas = action.params._reportDatas;
        if(_reportDatas){
            for(var i=0; i<_reportDatas.length; i++){
                sendMsg(_reportDatas[i]);
            }
        }else{
            sendMsg(action.params._reportData);
        }
    }

    var buliao_export_month_bill = function(element, action){
        framework.blockUI();
        session.get_file({
            'url': '/buliao/month_bill',
            'data': {'query': JSON.stringify(action.params.query)},
            'complete': framework.unblockUI,
            'error': crash_manager.rpc_error.bind(crash_manager)
        });
        element.do_action({'type':'ir.actions.act_window_close'});
    }

    core.action_registry.add('open_report', open_report);
    core.action_registry.add('cfprint_report', cfprint_report);
    core.action_registry.add('buliao_export_month_bill', buliao_export_month_bill);
});
